<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('用户供应列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>供应卡编号：</label>
                                <input type="text" name="supplyNo"/>
                            </li>
                            <li>
                                <label>配送卡状态：</label>
                                <select name="status" th:with="type=${@dict.getType('userSupplyCardStatus')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <!--<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:userSupplyCard:export">-->
                    <!--<i class="fa fa-download"></i> 导出-->
                <!--</a>-->
                <a class="btn btn-warning" id="importExcel">
                    <i class="fa fa-download"></i> 导入发货单
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:userSupplyCard:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:userSupplyCard:remove')}]];
        var prefix = ctx + "system/userSupplyCard";
        var statusDatas = [[${@dict.getType('userSupplyCardStatus')}]];

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "用户供应",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id', 
                    title: '主键ID',
                    visible: false
                },
                    {
                        field: 'supplyNo',
                        title: '供应卡编号'
                    },
                {
                    field: 'goodsName',
                    title: '产品名称'
                },
                {
                    field: 'typeName',
                    title: '类别'
                },
                {
                    field: 'className',
                    title: '类型'
                },
                {
                    field: 'supplyTypeName',
                    title: '供应卡类型'
                },
                {
                    field: 'supplySend', 
                    title: '配送方式'
                },
                {
                    field: 'total', 
                    title: '总量'
                },
                {
                    field: 'sendTotal', 
                    title: '已配送的数量'
                },
                {
                    field: 'status', 
                    title: '配送卡状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                {
                    field: 'consigneeName', 
                    title: '收货人名称'
                },
                {
                    field: 'consigneeMobile', 
                    title: '收货人电话'
                },
                {
                    field: 'area',
                    title: '地区'
                },
                {
                    field: 'address', 
                    title: '收货地址'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        if (row.status == 0){
                            actions.push('<a class="btn btn-danger btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="send(\'' + row.id + '\')"><i class="fa fa-send"></i>发货</a>');
                        }
                        actions.push('<a class="btn btn-danger btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="showLog(\'' + row.id + '\')"><i class="fa fa-send"></i>查看配送</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function send(id) {
            $.modal.open("发货", ctx+"/system/userSupplyCard/send/"+id);
        }
        function showLog(id) {
            $.modal.open("配送记录", ctx+"/system/userSupplyCard/showlog/"+id);
        }
        layui.use('upload', function () {
            var $ = layui.jquery
                , upload = layui.upload;

            //普通图片上传
            upload.render({
                elem: '#importExcel'
                , url: ctx+'/system/userSupplyCard/importExcel' //改成您自己的上传接口
                ,accept: 'file'
                , done: function (res) {
                    //如果上传失败
                    if (res.code > 0) {
                        return layer.msg('上传失败');
                    }
                    //上传成功
                    layer.msg('上传成功')
                }
            });
        });
    </script>
</body>
</html>